// MESSAGE ATTITUDE_BODY_DATA support class

#pragma once

namespace mavlink {
namespace fppa {
namespace msg {

/**
 * @brief ATTITUDE_BODY_DATA message
 *
 * ATTITUDE_BODY_DATA
 */
struct ATTITUDE_BODY_DATA : mavlink::Message {
    static constexpr msgid_t MSG_ID = 20;
    static constexpr size_t LENGTH = 116;
    static constexpr size_t MIN_LENGTH = 116;
    static constexpr uint8_t CRC_EXTRA = 219;
    static constexpr auto NAME = "ATTITUDE_BODY_DATA";


    uint32_t state; /*<  calculating state. */
    float q0; /*<  quaternion q0. */
    float q1; /*<  quaternion q1. */
    float q2; /*<  quaternion q2. */
    float q3; /*<  quaternion q3. */
    float roll; /*<  roll angle. */
    float pitch; /*<  pitch angle. */
    float yaw; /*<  yaw angle. */
    float bw_x; /*<  x axis angle speed in B coordinate. */
    float bw_y; /*<  y axis angle speed in B coordinate. */
    float bw_z; /*<  z axis angle speed in B coordinate. */
    float nw_x; /*<  x axis angle speed in N coordinate. */
    float nw_y; /*<  y axis angle speed in N coordinate. */
    float nw_z; /*<  z axis angle speed in N coordinate. */
    float bw_bia_x; /*<  Zero deviation of gyro x axis. */
    float bw_bia_y; /*<  Zero deviation of gyro y axis. */
    float bw_bia_z; /*<  Zero deviation of gyro z axis. */
    float ba_x; /*<  x axis acceleration in B coordinate. */
    float ba_y; /*<  y axis acceleration in B coordinate. */
    float ba_z; /*<  z axis acceleration in B coordinate. */
    float ba_bia_x; /*<  Zero deviation of gyro x axis acceleration. */
    float ba_bia_y; /*<  Zero deviation of gyro y axis acceleration. */
    float ba_bia_z; /*<  Zero deviation of gyro z axis acceleration. */
    float bm_x; /*<  x axis magnet in B coordinate. */
    float bm_y; /*<  y axis magnet in B coordinate. */
    float bm_z; /*<  z axis magnet in B coordinate. */
    float bm_bia_x; /*<  Zero deviation of magnet x axis. */
    float bm_bia_y; /*<  Zero deviation of magnet y axis. */
    float bm_bia_z; /*<  Zero deviation of magnet z axis. */


    inline std::string get_name(void) const override
    {
            return NAME;
    }

    inline Info get_message_info(void) const override
    {
            return { MSG_ID, LENGTH, MIN_LENGTH, CRC_EXTRA };
    }

    inline std::string to_yaml(void) const override
    {
        std::stringstream ss;

        ss << NAME << ":" << std::endl;
        ss << "  state: " << state << std::endl;
        ss << "  q0: " << q0 << std::endl;
        ss << "  q1: " << q1 << std::endl;
        ss << "  q2: " << q2 << std::endl;
        ss << "  q3: " << q3 << std::endl;
        ss << "  roll: " << roll << std::endl;
        ss << "  pitch: " << pitch << std::endl;
        ss << "  yaw: " << yaw << std::endl;
        ss << "  bw_x: " << bw_x << std::endl;
        ss << "  bw_y: " << bw_y << std::endl;
        ss << "  bw_z: " << bw_z << std::endl;
        ss << "  nw_x: " << nw_x << std::endl;
        ss << "  nw_y: " << nw_y << std::endl;
        ss << "  nw_z: " << nw_z << std::endl;
        ss << "  bw_bia_x: " << bw_bia_x << std::endl;
        ss << "  bw_bia_y: " << bw_bia_y << std::endl;
        ss << "  bw_bia_z: " << bw_bia_z << std::endl;
        ss << "  ba_x: " << ba_x << std::endl;
        ss << "  ba_y: " << ba_y << std::endl;
        ss << "  ba_z: " << ba_z << std::endl;
        ss << "  ba_bia_x: " << ba_bia_x << std::endl;
        ss << "  ba_bia_y: " << ba_bia_y << std::endl;
        ss << "  ba_bia_z: " << ba_bia_z << std::endl;
        ss << "  bm_x: " << bm_x << std::endl;
        ss << "  bm_y: " << bm_y << std::endl;
        ss << "  bm_z: " << bm_z << std::endl;
        ss << "  bm_bia_x: " << bm_bia_x << std::endl;
        ss << "  bm_bia_y: " << bm_bia_y << std::endl;
        ss << "  bm_bia_z: " << bm_bia_z << std::endl;

        return ss.str();
    }

    inline void serialize(mavlink::MsgMap &map) const override
    {
        map.reset(MSG_ID, LENGTH);

        map << state;                         // offset: 0
        map << q0;                            // offset: 4
        map << q1;                            // offset: 8
        map << q2;                            // offset: 12
        map << q3;                            // offset: 16
        map << roll;                          // offset: 20
        map << pitch;                         // offset: 24
        map << yaw;                           // offset: 28
        map << bw_x;                          // offset: 32
        map << bw_y;                          // offset: 36
        map << bw_z;                          // offset: 40
        map << nw_x;                          // offset: 44
        map << nw_y;                          // offset: 48
        map << nw_z;                          // offset: 52
        map << bw_bia_x;                      // offset: 56
        map << bw_bia_y;                      // offset: 60
        map << bw_bia_z;                      // offset: 64
        map << ba_x;                          // offset: 68
        map << ba_y;                          // offset: 72
        map << ba_z;                          // offset: 76
        map << ba_bia_x;                      // offset: 80
        map << ba_bia_y;                      // offset: 84
        map << ba_bia_z;                      // offset: 88
        map << bm_x;                          // offset: 92
        map << bm_y;                          // offset: 96
        map << bm_z;                          // offset: 100
        map << bm_bia_x;                      // offset: 104
        map << bm_bia_y;                      // offset: 108
        map << bm_bia_z;                      // offset: 112
    }

    inline void deserialize(mavlink::MsgMap &map) override
    {
        map >> state;                         // offset: 0
        map >> q0;                            // offset: 4
        map >> q1;                            // offset: 8
        map >> q2;                            // offset: 12
        map >> q3;                            // offset: 16
        map >> roll;                          // offset: 20
        map >> pitch;                         // offset: 24
        map >> yaw;                           // offset: 28
        map >> bw_x;                          // offset: 32
        map >> bw_y;                          // offset: 36
        map >> bw_z;                          // offset: 40
        map >> nw_x;                          // offset: 44
        map >> nw_y;                          // offset: 48
        map >> nw_z;                          // offset: 52
        map >> bw_bia_x;                      // offset: 56
        map >> bw_bia_y;                      // offset: 60
        map >> bw_bia_z;                      // offset: 64
        map >> ba_x;                          // offset: 68
        map >> ba_y;                          // offset: 72
        map >> ba_z;                          // offset: 76
        map >> ba_bia_x;                      // offset: 80
        map >> ba_bia_y;                      // offset: 84
        map >> ba_bia_z;                      // offset: 88
        map >> bm_x;                          // offset: 92
        map >> bm_y;                          // offset: 96
        map >> bm_z;                          // offset: 100
        map >> bm_bia_x;                      // offset: 104
        map >> bm_bia_y;                      // offset: 108
        map >> bm_bia_z;                      // offset: 112
    }
};

} // namespace msg
} // namespace fppa
} // namespace mavlink
